<?php
echo "<pre>\n";
$dbcnx = @mysql_connect("localhost", "root", "qqq");
mysql_query("SET NAMES utf8");
@mysql_select_db("vknew", $dbcnx);
//file to db
$filename="proxy.txt";
$fd = fopen($filename, "r");
$bufer = fread($fd, filesize($filename));
fclose($fd);
$bufer = split("\n", $bufer);
for($i = 0; $i < count($bufer); $i++) {
	$proxy  = substr($bufer[$i], 0, strpos($bufer[$i], ":"));
	$port   = substr($bufer[$i], strpos($bufer[$i], ":") + 1);
	$result = mysql_query("SELECT * FROM `proxy` WHERE proxy='".$proxy."'");
	if(mysql_fetch_row($result) == FALSE) {
		echo "i=".$i." proxy=".$bufer[$i]."\n";
		mysql_query("INSERT INTO `proxy` (proxy, port) VALUES ('".$proxy."', '".$port."')");	
	} else {
		echo "i=".$i." proxy=".$bufer[$i]." ALREADY EXISTS\n";
	}
}
mysql_close($dbcnx);
echo "\n</pre>";
?>
